package com.uzai.console.web.report;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.device.DeviceQuery;
import com.uzai.console.dto.report.*;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.device.DeviceService;
import com.uzai.console.service.report.OrderRevenueReportService;
import com.uzai.console.vo.device.DeviceInfoVo;
import com.uzai.console.vo.exportinfo.ExportAmountVo;
import com.uzai.console.vo.report.OrderRevenueIndicatorReportVo;
import com.uzai.console.vo.report.OrderRevenueReportVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 订单收益
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "订单收益",tags = "数据报表|订单收益")
@ApiSort(50)
@RestController
public class OrderRevenueReportController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(OrderRevenueReportController.class);

    @Autowired
    private DeviceService deviceService;
    @Autowired
    private OrderRevenueReportService orderRevenueReportService;

    @ApiOperation(value = "查询机器人下拉列表", notes = "查询机器人下拉列表", response = DeviceInfoVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/report/orderRevenue/findDeviceList")
    public Object findDeviceList(@RequestBody DeviceQuery deviceQuery) {
        deviceQuery.setMerId(getLoginInfo().getMerId());
        return deviceService.findDeviceList(deviceQuery);
    }

    @ApiOperation(value = "分页查询订单收益报表", notes = "分页查询订单收益报表", response = OrderRevenueReportVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/report/orderRevenueReport")
    public Object orderRevenueReport(@RequestBody OrderRevenueReportQuery orderRevenueReportQuery){
        return orderRevenueReportService.orderRevenueReport(orderRevenueReportQuery);
    }

    @ApiOperation(value = "统计订单收益指标", notes = "统计订单收益指标", response = OrderRevenueIndicatorReportVo.class)
    @ApiOperationSupport(order = 3)
    @PostMapping("/report/orderRevenueIndicator")
    public Object orderRevenueIndicator(@RequestBody OrderRevenueIndicatorDto orderRevenueIndicatorDto){
        return orderRevenueReportService.orderRevenueIndicator(orderRevenueIndicatorDto);
    }

    @ApiOperation(value = "订单收益查询结果导出文件前检验接口", notes = "订单收益查询结果导出文件前检验接口", response = ExportAmountVo.class)
    @ApiOperationSupport(order = 4)
    @PostMapping("/report/orderRevenue/getExportAmount")
    public Object getExportAmount(@RequestBody OrderRevenueReportQuery orderRevenueReportQuery){
        return orderRevenueReportService.getExportAmount(orderRevenueReportQuery);
    }

    @SystemLogType(model = SystemModelEnum.OrderRevenueReport, type = OperationTypeEnum.EXPORT)
    @ApiOperation(value = "订单收益报表查询结果导出文件", notes = "订单收益报表查询结果导出文件")
    @ApiOperationSupport(order = 5)
    @PostMapping("/report/orderRevenue/exportByQeuryResult")
    public Object exportByQeuryResult(@RequestBody OrderRevenueReportExportResultDto orderRevenueReportExportResultDto){
        orderRevenueReportService.exportByQeuryResult(orderRevenueReportExportResultDto);
        return true;
    }

}
